//
//  FourVC.m
//  Logistics
//
//  Created by 恩州科技 on 2018/8/4.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "FourVC.h"
#import "FourListTVCell.h"
#import "MyInformationVC.h"
#import "TheMessageVC.h"
#import "SetUpTheVC.h"
#import "ToBeProcessedViewController.h"
#import "MyWalletVC.h"
#import "CompletedVC.h"
@interface FourVC ()<UITableViewDelegate,UITableViewDataSource,FourListTVCellDelegate,FourListTVCellSecondDelegate>
@property (nonatomic,strong) UIView *headView;
@property (nonatomic,strong) UIButton *leftBut;
@property (nonatomic,strong) UIButton *rightBut;
@property (nonatomic,strong) UITableView *listTV;

@end

@implementation FourVC
-(UITableView *)listTV{
    if (!_listTV) {
        _listTV = [[UITableView alloc]initWithFrame:CGRectMake(GTFixWidthFlaot(20),  kMainTopHeight + GTFixHeightFlaot(45), kMainScreen_width -GTFixWidthFlaot(40) , kMainScreen_height-self.headView.height - GTFixHeightFlaot(37)) style:UITableViewStyleGrouped];
        _listTV.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];;
        _listTV.showsVerticalScrollIndicator = NO;
        _listTV.separatorStyle = UITableViewCellSeparatorStyleNone;
        _listTV.dataSource = self;
        _listTV.delegate = self;
    }
    return _listTV;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navView.hidden= YES;
    self.view.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];
    [self.view addSubview:self.listTV];
    [self createHeadView];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        FourListTVCell *cell=[tableView dequeueReusableCellWithIdentifier:@"FourListTVCell"];
        if (!cell) {
            cell=[[FourListTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FourListTVCell"];
        }
        cell.indexPath = indexPath;
        cell.delegate =self;
        cell.layer.cornerRadius = 5.0;
        return cell;
    }else if(indexPath.section == 1){
        FourListTVCellSecond *cell=[tableView dequeueReusableCellWithIdentifier:@"FourListTVCellSecond"];
        if (!cell) {
            cell=[[FourListTVCellSecond alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FourListTVCellSecond"];
        }
        //fourListSecondwithIndexPath
        cell.indexPath = indexPath;
        cell.delegate =self;
        cell.layer.cornerRadius = 5.0;
        return cell;
    }else{
        FourListTVCellThree*cell = [tableView dequeueReusableCellWithIdentifier:@"FourListTVCellThree"];
        if (!cell) {
            cell=[[FourListTVCellThree alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FourListTVCellThree"];
        }
        cell.layer.cornerRadius = 5.0;
        return cell;
    }
}
#pragma  mark -----cell代理
-(void)fourListwithIndexPath:(NSIndexPath *)index withtype:(NSString *)type{
    if ([type isEqualToString:@"1"]) {
        ToBeProcessedViewController * tbVC = [ToBeProcessedViewController new];
        [self.navigationController pushViewController:tbVC animated:YES];
    }else{
        CompletedVC * vc = [CompletedVC new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(void)fourListSecondwithIndexPath:(NSIndexPath *)index withtype:(NSString *)type{
    if ([type isEqualToString:@"1"]) {
       
    }else{
        MyWalletVC * vc = [MyWalletVC new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return GTFixHeightFlaot(70);
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return GTFixHeightFlaot(10);
}
-(void)createHeadView {
    self.headView = [UIView new];
    self.headView.backgroundColor = [UIColor colorWithRed:46/255.0 green:54/255.0 blue:77/255.0 alpha:1];
    UILabel * titleLab = [UILabel labelWithSize:[UIFont systemFontOfSize:18] withColor:[UIColor whiteColor] withText:@"我的"];
    self.leftBut = [UIButton buttonWithTitle:nil withImageName:@"shangchuanweixiu" withBGColor:nil Withlayer:NO];
    [self.leftBut addTarget:self action:@selector(leftButClieck:) forControlEvents:UIControlEventTouchUpInside];
    self.rightBut = [UIButton buttonWithTitle:nil withImageName:@"shangchuanweixiu" withBGColor:nil Withlayer:NO];
    [self.rightBut addTarget:self action:@selector(rightButClieck:) forControlEvents:UIControlEventTouchUpInside];
    UIImageView * iamgeHead  = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"touxiangMN"]];
    iamgeHead.userInteractionEnabled = YES;
    [iamgeHead addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
        MyInformationVC * vc = [MyInformationVC new];
        [self.navigationController pushViewController:vc animated:YES];
    }];
    UILabel * telLab = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:[UIColor whiteColor] withText:@"15788779999"];
    UIImageView * plaintImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"weorenzheng"]];
    UILabel * isORnoLab = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:[UIColor whiteColor] withText:@"未验证"];
    UIImageView * jiantouImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jiantouhui"]];
    UILabel * labelLin = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:[UIColor whiteColor] withText:nil];
    labelLin.backgroundColor = [UIColor colorWithRed:106/255.0 green:183/255.0 blue:234/255.0 alpha:1];

    [self.view addSubview:self.headView];
    [self.headView addSubview:titleLab];
    [self.headView addSubview:self.leftBut];
    [self.headView addSubview:self.rightBut];
    [self.headView addSubview:iamgeHead];
    [self.headView addSubview:telLab];
    [self.headView addSubview:plaintImage];
    [self.headView addSubview:isORnoLab];
    [self.headView addSubview:jiantouImage];
    [self.headView addSubview:labelLin];
   
    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(kMainScreen_width);
        make.height.mas_equalTo(kMainTopHeight + GTFixHeightFlaot(45));
    }];
    [self.leftBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(GTFixHeightFlaot(20));
        make.left.mas_equalTo(GTFixWidthFlaot(15));
        make.width.height.mas_equalTo(GTFixHeightFlaot(20));
    }];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(GTFixHeightFlaot(20));
        make.left.mas_equalTo(kMainScreen_width/2 - 20 );
        make.height.mas_equalTo(GTFixHeightFlaot(20));
        make.width.mas_equalTo(GTFixWidthFlaot(40));
    }];
    [self.rightBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(GTFixHeightFlaot(20));
        make.right.mas_equalTo(GTFixWidthFlaot(-10));
        make.width.height.mas_equalTo(GTFixHeightFlaot(20));
    }];
    [iamgeHead mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftBut.mas_bottom).offset(GTFixHeightFlaot(5));
        make.left.mas_equalTo(GTFixWidthFlaot(18));
        make.width.height.mas_equalTo(GTFixHeightFlaot(40));
    }];
    [telLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftBut.mas_bottom).offset(GTFixHeightFlaot(20));
        make.left.mas_equalTo(iamgeHead.mas_right).offset(GTFixWidthFlaot(10));
        make.width.mas_equalTo(telLab.mas_width);
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [plaintImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftBut.mas_bottom).offset(GTFixHeightFlaot(22));
        make.right.mas_equalTo(GTFixWidthFlaot(-70));
        make.width.height.mas_equalTo(GTFixHeightFlaot(10));
    }];
    [isORnoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftBut.mas_bottom).offset(GTFixHeightFlaot(20));
        make.right.mas_equalTo(GTFixWidthFlaot(-35));
        make.width.mas_equalTo(isORnoLab.mas_width);
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [jiantouImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftBut.mas_bottom).offset(GTFixHeightFlaot(21));
        make.right.mas_equalTo(GTFixWidthFlaot(-15));
        make.height.mas_equalTo(GTFixHeightFlaot(13));
        make.width.mas_equalTo(GTFixWidthFlaot(10));
    }];
    [labelLin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(GTFixHeightFlaot(0));
        make.left.mas_equalTo(GTFixWidthFlaot(0));
        make.height.mas_equalTo(GTFixHeightFlaot(1));
        make.width.mas_equalTo(kMainScreen_width);
    }];
}
-(void)leftButClieck:(UIButton *)btn {
    TheMessageVC * vc = [TheMessageVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)rightButClieck:(UIButton *)btn {
    SetUpTheVC * vc = [SetUpTheVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
